<%@page import="com.tcs.service.RequisitionService"%>
<%@page import="javax.annotation.Resource"%>
<%@page import="javax.swing.Timer"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@page import="com.tcs.model.User"%>
<%@ page session="true"%>
<%
	User usuario = null;
	HttpSession sesionOk = request.getSession();
	if (sesionOk.getAttribute("usuario") == null) {
%>
<jsp:forward page="index.jsp">
	<jsp:param name="error" value="Es obligatorio identificarse" />
</jsp:forward>
<%
	} else {
		usuario = (User) sesionOk.getAttribute("usuario");
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
</head>
  <body>
<div id="header">
	<div class="navbar">
		<div class="navbar-inner">
			<div class="container-fluid">
				<a class="brand" href="#">TCS<span class="slogan">Pedidos
						Online</span></a>
				<div class="nav-no-collapse">
					<ul class="nav pull-right usernav">



						<li>Hola! <%=usuario.getFirstName()%></li>
						<%
							if (((User) sesionOk.getAttribute("usuario")).getPermission()
									.getPermissionType() == 0) {
						%>
				
					
						<li><ul id="broadcast-msg"></ul></li>

						<!-- Include the socket.io javascript on the client side -->
						<li><script
								src="http://localhost:8000/socket.io/socket.io.js"></script> <script
								src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script>
									// Establish the connection with the server
									var socket = io
											.connect('http://localhost:8000');

									// on every message recived we print the new datas inside the #broadcast-msg div
									socket.on('broadcast_msg', function(data) {
										console.log('Get broadcasted msg:',
												data);
										
										$.pnotify({
										    title: 'Nuevo Pedido',
										    text: data,
										    type: 'success'
										    });
										
										
										//var msg = '<li>' + data + '</li>$tag';
									//	$('#broadcast-msg').html(msg);
									});

									// Create a new socket connection
									socket.on('connect', function() {

										socket.emit('set nickname', 'admin');

									});
								</script> <%
 	}
 %>
						<li><a href="logout.html"><span
								class="icon16 icomoon-icon-exit"></span> Logout</a></li>
					</ul>
				</div>
				<!-- /.nav-collapse -->
			</div>
		</div>
		<!-- /navbar-inner -->
	</div>
	<!-- /navbar -->
</div>
<!-- End #header -->


	  </body>
</html>